package com.atguigu.controller;

import com.atguigu.entity.User2;
import com.atguigu.resp.ResultData;
import com.atguigu.service.User2Service;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import java.io.Serializable;

@Slf4j
@RestController
@RequestMapping("/user")
public class UserController {

    @Resource
    private User2Service userService;
    @RequestMapping("/{id}")
    public ResultData<User2> getUser(@PathVariable("id")Serializable id) {
        return ResultData.success(userService.getById(id)) ;
    }

    @PostMapping("/add")
    public ResultData<Boolean> addUser(@RequestBody User2 user) {
        return ResultData.success(userService.save(user)) ;
    }


}
